//
//  ControllerTool.m
//  CC
//
//  Created by Calvin on 5/13/15.
//  Copyright (c) 2015 Calvin. All rights reserved.
//

#import "ControllerTool.h"
#import "TabBarViewController.h"
#import "AuthViewController.h"

@implementation ControllerTool
+(void)chooseRootViewController
{
    UIWindow *window =[UIApplication sharedApplication].keyWindow;
    NSString *versioKey = @"CFBundleVersion";
    versioKey= (__bridge NSString *)kCFBundleVersionKey;
    
    //get the version information from the sandbox
    NSUserDefaults *defaults = [[NSUserDefaults alloc] init];
    NSString *lastVersion = [defaults objectForKey:versioKey];
    
    //get current version information
    NSString *currentVersion = [NSBundle mainBundle].infoDictionary[versioKey];
    if ([currentVersion isEqualToString:lastVersion]) {
        window.rootViewController = [[TabBarViewController alloc] init];
    }
    else
    {
//        window.rootViewController=
        [defaults setObject:currentVersion forKey:versioKey];
        [defaults synchronize];
    }
}
@end
